import colorCofig from "@/config/color.js"
const dynamicUtil = {
    getHeight(height) {
        if (height) {
            return height * 2 + "rpx"
        }
        return "0rpx"
    },
    getMainColor() {
        return colorCofig.color.main
    },
    getNewArray(arr, size) {
        // size，要分割的长度
        const arrNum = Math.ceil(arr.length / size, 10) // Math.ceil()向上取整的方法，用来计算拆分后数组的长度
        let index = 0 // 定义初始索引
        let resIndex = 0 // 用来保存每次拆分的长度
        const result = []
        while (index < arrNum) {
            result[index] = arr.slice(resIndex, size + resIndex)
            resIndex += size
            index++
        }
        return result
    },
}

module.exports = {
    getHeight: dynamicUtil.getHeight,
    getMainColor: dynamicUtil.getMainColor,
    getNewArray: dynamicUtil.getNewArray,
}
